function userLogin() {
    let email = $("#email").val();
    let password = $("#password").val();
    $.post("/blog/user/login",
        {
            email:email,
            password:password,
        },
        function(data,status){
            let arr = new Array('email','password');
            //提示语隐藏,出现弹出层
            $.each(arr,function(index,value){
                $("#invalid-"+value).css("display",'none');
            });
            if (status == 'success')
            {
                if(data.message == 'UserLogin')
                {
                    $.each(arr,function(index,value){
                        if(data['data'][value])
                        {
                            $("#invalid-"+value).html(data['data'][value]).css("display",'block');
                        }
                    });
                    setTimeout(function () {
                        window.location.href = data['data']['back_url'];
                    } , 5000);
                }
                else if(data.message == 'register')  //未注册的用户
                {
                    $("#modal-register").css('display','block');
                    $("#modal-register #register-now").attr("href",data['data']['back_url']);
                    //定时跳转
                    let timer = setInterval(function () {
                        showRegister(timer,5)
                    }, 1000);
                    setTimeout(function () {
                        window.location.href = data['data']['back_url'];
                    } , 5000);
                }
                else
                {
                    if(data['data']['token'])
                    {
                        $("#modal-success").css('display','block');
                        $("#modal-success #experience-now").attr("href",data['data']['back_url']);
                        //定时跳转
                        let timer = setInterval(function () {
                            showCountDown(timer,3)
                        }, 1000);
                        setTimeout(function () {
                            window.location.href = data['data']['back_url'];
                        } , 3000);
                    }
                    else
                    {
                        $("#modal-danger").css('display','block');
                    }
                }
            }
            else
            {
                $("#modal-danger").css('display','block');
            }
        },"json");
};
function showCountDown(timer,after)
{
    let experience_now_after =$("#experience-now-after");
    let experience_now_time = $("#experience-now-time");
    let time = parseInt(experience_now_after.val());
    time++;
    if (time > after) {
        clearInterval(timer);//需要清除计时器
    }
    else {
        experience_now_time.html(time+'s');
        experience_now_after.val(time);
    }
}
function showRegister(timer,after)
{
    let register_now_after =$("#register-now-after");
    let register_now_time = $("#register-now-time");
    let time = parseInt(register_now_after.val());
    time++;
    if (time > after) {
        clearInterval(timer);//需要清除计时器
    }
    else {
        register_now_time.html(time+'s');
        register_now_after.val(time);
    }
}
function showPassword()
{
    let password_type = $("#password").prop("type");
    if(password_type == 'text')
    {
        $("#password").prop("type","password");
    }
    else
    {
        $("#password").prop("type","text");
    }
}
$("#register-success").click(function () {
    $("#modal-success").css('display','none');
});
$("#register-fail").click(function () {
    $("#modal-danger").css('display','none');
});
$("#not-register").click(function () {
    $("#modal-register").css('display','none');
});
